<?php

namespace App\Http\Controllers\Api;

use App\Exceptions\ResponseException;
use App\Handler\ImageHandler;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class BaseController extends Controller
{
	use ImageHandler;
	/**
	 * 公用的上传图片
	 * User: Clannad ~ ☆
	 * DateTime: 2019/11/1 22:31
	 */
	public function uploadImg(Request $request)
    {
		if($request->hasFile('thumb')){
		    $img = $this->imageUploader('uploads/user','thumb');

		    if($img['status'] == 200){
				throw new ResponseException(200,'ok',env('APP_URL') . '/' . $img['path']);
		    }else{
		    	throw new ResponseException(500,$img['msg']);
			}
		}else{
			throw new ResponseException(415,'没有上传文件');
		}
    }
}
